package com.fastwire.carriere.rad.dao;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.fastwire.carriere.dao.DAOException;
import com.fastwire.carriere.rad.entity.RadAlarm;

/*
 * Creted on 20120225
 * @author: Lei Jun
 */
public class RadAlarmDaoImp extends AbstractRadDaoImp implements RadAlarmDao
{
	@Override
	public void saveOrUpdate(RadAlarm alrm) throws DAOException 
	{
		// TODO Auto-generated method stub
		try 
		{
			super.saveOrUpdate(alrm);
		}
		catch (com.fastwire.carriere.dao.DAOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void saveOrUpdate(List<RadAlarm> alarms) throws DAOException
	{
		super.saveOrUpdateAll(alarms);
	}

    /* (non-Javadoc)
     * @see com.fastwire.carriere.rad.dao.RadAlarmDao#getAlarmByIP(java.lang.String)
     */
    @Override
    public List<RadAlarm> getAlarmByIP(String ip) throws DAOException
    {
        DetachedCriteria criteria = DetachedCriteria.forClass(RadAlarm.class);

        criteria.add(Restrictions.eq("ipAddr", ip));

        return getHibernateTemplate().findObjsByCriteria(criteria, true, false);
    }
}
